package nb.yan.service.impl;

import nb.yan.dao.OrderDao;
import nb.yan.entity.Order;
import nb.yan.service.OrderService;
import nb.yan.util.OrderIdGenerator;

public class OrderServiceImpl implements OrderService {
	
	private OrderDao orderDao;

	public OrderServiceImpl(OrderDao orderDao) {
		super();
		this.orderDao = orderDao;
	}

	@Override
	public Order order(Order order) {
		order.setOrderId(OrderIdGenerator.generate());
		return this.orderDao.add(order);
	}

	@Override
	public Order[] orderList() {
		return this.orderDao.getAll();
	}

	@Override
	public boolean checkOrder(int orderId) {
		return this.orderDao.modifyStatusById(orderId) > 0;
	}

	@Override
	public boolean deleteOrder(int orderId) {
		return this.orderDao.deleteById(orderId) > 0;
	}
	
}
